﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using PJ.Business.Partner;
using PJ.Business.Inventory;

namespace PJ.Business.SalePurchase
{
    public interface IShoppingCartItemService : IOrderedFragmentService, IShoppingCartFragmentService, IInventoryItemDependentService, IInventoryItemOrderParamDependentService
    {
        /// <summary>
        /// Decodes a user expression string. 
        /// </summary>
        /// <param name="expression">the user expression to decode</param>
        /// <param name="itemId">Found Item id</param>
        /// <param name="quantity">Decoded Quantity</param>
        /// <param name="unitId">Quantity unit id. From barcode if used or default item unit.</param>
        /// <returns>true if decoded without errors and item found, else return false. Out parameters have default values if returns false.</returns>
        /// <remarks>The last '*' in the expression will seperate quantity expression from item expresssion.
        /// If the item expression is a barcode the returned quantity is the barcode's quantity multiplied by user expression quantity.
        /// If there are not any quantity defined in the expression, the default item quantity will be returned
        /// </remarks>
        /// <example>3*56+3*itemabc => 
        ///             Quantity expression = 3*56+3 = 171
        ///             Item expression = itemabc = IT25664 (itemabc is alias of IT25664)
        /// </example>
        bool DecodeExpression(string expression, out string itemId, out double quantity, out string unitId);

        /// <summary>
        /// Find an item.
        /// </summary>
        /// <param name="identifier">the item's id, name alias or barcode can be used.</param>
        /// <param name="itemId">found item id</param>
        /// <param name="quantity">the barcode quantity if used</param>
        /// <param name="defaultQuantity">the default item order quantity</param>
        /// <param name="unitId">The default item order unit id or barcode unit id if used.</param>
        /// <returns>true if the item is found else false. Out parameters have default values if returns false</returns>
        bool FindItemId(string identifier, out string itemId, out double quantity, out double defaultQuantity, out string unitId);

    }
    public interface IShoppingCartItemService<TIShoppingCartItem> : IOrderedFragmentService<TIShoppingCartItem>, IShoppingCartItemService
        where TIShoppingCartItem : class, IShoppingCartItem
    {
    }
}
